import Vue from 'vue'
import Vuex from 'vuex'

import gongLue from './gongLue/index.js'

Vue.use(Vuex)

const store = new Vuex.Store({
	state:{
		//获取当前位置
		localPosition:'',
		//选择当前位置
		choosePosition:'',
		//攻略tabbar点击状态
		tabInd:null,
		//宾馆价格
		hotelPrice:'',
		//宾馆星级
		hotelStar:'',
		// 监听页面滚动
		scroll:null,
		// 显示行程产品选择
		showXcType:false,
		// 添加成功组件
		showAddCuss:{
			show:false,
			text:'',
			url:''
		},
		// 置顶
		showToTop:false,
		//语音播放控件
		showAudioPlayer:{
			show:false,
			playing:false,
			nowTime:0,
			sumTime:0
		},
		//宾馆开始日期
		startTime:null,
		//宾馆结束日期
		endTime:null,
		//短信计时器
		msgTime:{
			begin:false,
			time:60
		},
		//宾馆搜索
		hotelSearchText:'',
		//typeTop
		typeTop:false,
	},
	getters:{
		
	},
	mutations:{
		//更新当前位置
		localPositionUpdata(state,payload){
			state.localPosition = payload
		},
		// 更新选择当前位置
		choosePositionUpdata(state,payload){
			state.choosePosition = payload
		},
		// 更新攻略tabbar点击状态
		tabIndexUpdata(state,payload){
			state.tabInd = payload
		},
		//更新宾馆价格
		hotelPriceUpdata(state,payload){
			state.hotelPrice = payload
		},
		//更新宾馆星级
		hotelStarUpdata(state,payload){
			state.hotelStar = payload
		},
		// 更新页面滚动位置
		scrollUpdate(state,payload){
			state.scroll = payload
		},
		// 显示行程产品选择
		showXcTypeUpdate(state,payload){
			state.showXcType = payload
		},
		// 添加成功组件
		showAddCussUpdate(state,payload){
			state.showAddCuss = payload
		},
		//置顶
		showToTopUpdate(state,payload){
			state.showToTop = payload
		},
		//语音播放控件
		showAudioPlayerUpdate(state,payload){
			state.showAudioPlayer = payload
		},
		//宾馆开始日期
		startTimeUpdate(state,payload){
			state.startTime = payload
		},
		//宾馆结束日期
		endTimeUpdate(state,payload){
			state.endTime = payload
		},
		//短信计时器
		msgTimeUpdate(state,payload){
			if(!state.msgTime.begin){
				state.msgTime.begin = true
				let timer = setInterval(()=>{
					--state.msgTime.time
				},1000)
				setTimeout(()=>{
					clearInterval(timer);
					state.msgTime.begin=false;
					state.msgTime.begin = 60;
				},60000);
			}
		},
		//宾馆搜索
		hotelSearchTextUpdate(state,payload){
			state.hotelSearchText = payload
		},
		typeTopUpdate(state,payload){
			state.typeTop = payload
		}
	},
	actions:{
		
	},
	
	modules:{
		gongLue
	}
})

export default store



